//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.Problem;
import com.hl.sfzy.entity.Reply;
import com.hl.sfzy.mapper.ReplyMapper;
import com.hl.sfzy.service.ReplyService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("Replyservice")
public class ReplyServiceImpl implements ReplyService {
    @Autowired
    private ReplyMapper replyMapper;

    public ReplyServiceImpl() {
    }

    public void add(Reply entity) throws Exception {
        this.replyMapper.insert(entity);
    }

    public void edit(Reply entity) {
    }

    public void remove(Integer id) {
        this.replyMapper.delete(id);
    }

    public void removeBatch(Integer[] ids) {
        this.replyMapper.deleteBatch(ids);
    }

    public List<Reply> find(Reply entity) {
        return this.replyMapper.select(entity);
    }

    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, Reply entity) {
        PageHelper.startPage(pageNum, pageSize);
        List<Reply> list = this.replyMapper.select(entity);
        PageInfo<Reply> pageInfo = new PageInfo(list);
        Map<String, Object> pageMap = new HashMap();
        pageMap.put("list", list);
        pageMap.put("total", pageInfo.getTotal());
        return pageMap;
    }

    public Reply findById(Integer id) {

        return null;
    }

    public List<Reply> selectByProblemId(Integer problemid) {
        return replyMapper.selectByProblemId(problemid);
    }

    /**
     * 根据用户id查对应的回答
     * @param userId
     * @return 回答id和回答内容
     */
    public List<Reply> selectByUserId(Integer userId){
        return replyMapper.selectByUserId(userId);
    }

    /**
     * 根据回答id差问题内容
     * @param replyId
     * @return 问题题目和问题的具体内容
     */
    public Problem selectByReplyId(Integer replyId){
        return replyMapper.selectByReplyId(replyId);
    }
}
